import QtQuick 1.0
import "common"
import "connectionpage.js" as JS
Item {
    id:root

    Component.onCompleted: JS.load()

    ListModel {
        id:listModel
    }

    ListView {
        id:view
        width: root.width
        height: root.height
        model: listModel
        clip: true
        delegate: OMenuItem {
            title: m_title
            subTitle: index ? m_ip+":"+m_port : "add a new connection"
            icon: index ?"gfx/wifi.png" : "gfx/add.png"




            onClicked: {
                if (!index)
                    dialog.show=true;
                else {
                    ftpModel.connectToHost(m_ip,m_port);
                    ftpModel.login(m_user,m_password);
                }

            }

            onPressAndHold: {
                if (!index) return;
                view.currentIndex = index;
                remDialog.show = true;
            }

        }
    }


    MenuDialog {
        id:dialog
        width: root.width
        height: root.height
        onAccept: JS.save()
    }

    ODialog {
        id:remDialog
        width: root.width
        height: root.height
        onAccept: JS.remove()
        content: "Remove this connection ? "
    }

}
